/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package FeeDeposit;

import Admission.AdmissionBean;
import Course.CourseBean;
import Student.StudentBean;
import StudentFeesDetail.StudentFeeDetailsBean;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Vector;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Mukesh
 */
public class GetFeeReminder extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            int sem=0,stream=0;
            String course = request.getParameter("course");
            if (request.getParameter("stream").length() != 0) {
                stream = Integer.parseInt(request.getParameter("stream"));
            }
            if (request.getParameter("sem").length() != 0) {
                sem = Integer.parseInt(request.getParameter("sem"));
            }

            Vector list = Query.getFeeReminder(course, stream, sem);
            Iterator it = list.iterator();
            while (it.hasNext()) {
                StudentBean sb = (StudentBean) it.next();
                StudentFeeDetailsBean sfd = sb.getStudentFeesDetailBean();
                AdmissionBean ab = sb.getAdmissionBean();
                CourseBean cb = ab.getCourseBean();

                out.println("<tr id='" + sb.getAdmissionId() + "'>");
                out.println("<td><center>");
                out.println(sb.getAdmissionId());
                out.println("</center></td>");
                out.println("<td><center>");
                out.println(sb.getStudentName());
                out.println("</center></td>");

                out.println("<td><center>");
                out.println(cb.getCourseName());
                out.println("</center></td>");
                out.println("<td><center>");
                out.println(sfd.getAmount());
                out.println("</center></td>");
                out.println("<td><center>");
                out.println(sfd.getAmountPaid());
                out.println("</center></td>");
                out.println("<td><center>");
                out.println(sfd.getAmount() - sfd.getAmountPaid());
                out.println("</center></td>");

                out.println("</tr>");
            }
        } catch (Exception e) {
            out.println("Notification Not Found.(e)");
        } finally {
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
